#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000007, maxn = 100+5;
ll d[maxn][maxn][maxn], N, M, A[maxn];

ll DP(int n, int i, int k){
    ll& ans = d[n][i][k];
    if(ans) return ans;
    ans = 0;
    if(k>=2 && k<=A[i]){
        ans = max(ans, DP(n, i, k-1) + 1);
    }
    if(i>=2)
        for (int b = 1; b <= A[i-1]; ++b) {
            ans = max(ans, DP(n, i-1, b)+1);
        }
    return ans;
}
int main() {
    cin >> N >> M;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        if(A[i]) d[1]
    }
    d[1][1][1] = 1;

    cout << DP(N, N, M)%mod;
    return 0;
}
